package com.mindskip.xzs.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum ExamTypeEnum {

    Fixed(1, "固定考试"),
    TimeLimit(4, "时段考试");

    Integer code;
    String name;

    public static ExamTypeEnum of(int code) {
        return Stream.of(ExamTypeEnum.values())
                .filter(it -> it.getCode() == code)
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("未找到该枚举类型：" + code));
    }
}
